home *** CD-ROM | disk | FTP | other *** search
- /************************************/
- /* File: Donald Koscheka.c */
- /* */
- /* -------------------------------- */
- /* ©1990 Donald Koscheka */
- /* All Rights Reserved */
- /************************************/
-
- #include <HyperXCMD.h>
- #include <HyperUtils.h>
- #include <SetUpA4.h>
-
- #ifndef MouseMovedEvt
- #define MouseMovedEvt 0xFA /* Mouse moved event code */
- #endif
-
- #ifndef SuspendResumeEvt
- #define SuspendResumeEvt 0x01 /* Suspend/Resume event code */
- #endif
-
- #define ResumeEvtMask 0x1 /* Supend or Resume selector */
- #define ConvertScrapMask 0x2 /* Scrap conversion flag */
-
-
- pascal void HandleHCEvent( XCmdPtr pp);
- pascal void HandleHCMessage( XCmdPtr pp);
- pascal void UpdateWindow( WindowPtr wind );
- pascal void DoContent( WindowPtr wind, XWEventInfoPtr ip);
-
-
-
- pascal void main( pp )
- XCmdPtr pp;
- /************************************
- * MAIN ENTRY POINT
- ************************************/
- {
-
- pp->returnValue = NIL;
-
- if( pp->paramCount < 0 )
- HandleHCEvent( pp );
- else{
- if( pp->paramCount == 1 )
- if( **(pp->params[0]) == '!' || **(pp->params[0]) == '?' ){
- switch( **(pp->params[0]) ){
- case '!':
- pp->returnValue = PASTOZERO( pp, "\pWindoids ©1990, 1991 Donald Koscheka, Inc.");
- return;
-
- case '?':
- pp->returnValue = PASTOZERO( pp, "\pWindoids [command] <parameters>" );
- return;
- }
- }
-
- HandleHCMessage( pp );
- }
-
- UnloadA4Seg( 0L );
- RestoreA4();
- }
-
-
-
- pascal void HandleHCEvent( pp )
- XCmdPtr pp;
- /**********************************
- * Handle events in our xWindows
- * returns true if the event was handled ok
- **********************************/
- {
- short windoPart;
- Rect r;
- XWEventInfoPtr ip = pp->params[0];
- WindowPtr whichWindow;
-
- pp->passFlag = FALSE;
-
- switch( ip->event.what ){
- case mouseDown:
- whichWindow = ip->eventWindow;
- windoPart = FindWindow( ip->event.where, &whichWindow );
-
- if( whichWindow )
- switch ( windoPart ){
- case inGoAway:
- if (TrackGoAway( whichWindow, ip->event.where) ){
- CLOSEXWINDOW( pp,whichWindow );
- pp->passFlag = FALSE;
- }
- break;
-
- case inDrag:
- /* handled by hypercard */
- pp->passFlag = TRUE;
- break;
-
- case inGrow:
- break;
-
- case inContent:
- if (whichWindow != FrontWindow() )
- SelectWindow( whichWindow );
- else{
- DoContent( whichWindow, ip );
- }
- pp->passFlag = TRUE;
- break;
-
- default:
- break;
- }/* window part */
- break;
-
- case mouseUp:
- break;
-
- case keyDown:
- case autoKey:
- break;
-
- case activateEvt:
- /* [DK] ON ACTIVATE, DRAW THE MENUS, ON DEACTIVATE HIDE THE MENUS */
- if ( ip->event.modifiers & activeFlag ){
- r= (ip->eventWindow)->portRect;
- InvalRect( &r );
- }
- pp->passFlag = TRUE;
- break;
-
- case updateEvt:
- UpdateWindow( ip->eventWindow );
- pp->passFlag = TRUE;
- break;
-
- case app4Evt:
- {
- unsigned char *evtType = &(ip->event.message);
-
- switch( *evtType ){
- case MouseMovedEvt:
- break;
-
- case SuspendResumeEvt:
- if( ip->event.message & ResumeEvtMask )
- show_all_windows();
- else
- hide_all_windows();
- break;
- }
- }
- pp->passFlag = TRUE;
- break;
-
- case xOpenEvt:
- ShowWindow( ip->eventWindow );
- pp->passFlag = TRUE;
- break;
-
- case xCloseEvt:
- pp->passFlag = TRUE;
- break;
-
- default:
- break;
- } /* switch theEvent->what */
- }
-
-
-
- pascal void DoContent( wind, ip )
- WindowPtr wind;
- XWEventInfoPtr ip;
- /*************************************
- * Handle the content region in a mouse
- * down in an xwindow. ip is a pointer
- * to the HyperXevent record, needed
- * to see where the mouse is and what the
- * modifiers are.
- *************************************/
- {
- SetPort( wind );
- }
-
-
- pascal void HandleHCMessage( pp )
- XCmdPtr pp;
- /*****************************************
- * Hypercard has sent us a message which we
- * need to respond to. The command is passed in
- * parameter 1 and the arguments are passed
- * in parameter 2..N
- *
- * Perhaps you'll add a little parser here
- * to accept valid commands and dispatch to
- * the correct command handler. You may pass
- * a command here called "openwindow" and another
- * called "closewindow" to allow the user to
- * create and destroy external windows.
- *****************************************/
- {
- }
-
-
-
- pascal void UpdateWindow( xwind )
- WindowPtr wind;
- /******************
- * Draw the contents of the window.
- *
- * You need to develop some mechanism
- * for storing window specific data.
- * You might try storing the info
- * in the window's refcon. The choice
- * is up to you.
- ******************/
- {
- BeginUpdate( wind );
- SetPort( wind );
- ClipRect( &wind->portRect );
- EndUpdate( wind );
- }
-
-